package com.wang.java.basic.features.reference;

import java.lang.ref.WeakReference;
import java.util.concurrent.TimeUnit;

public class WeakReferenceTest {
    public static void main(String[] args) throws InterruptedException {
        byte[] bytes = new byte[1024 * 1024];
        WeakReference<byte[]> weakReference = new WeakReference(bytes);
        System.out.println(weakReference.get());
        // 通知系统GC
        System.gc();
        TimeUnit.SECONDS.sleep(1);
        System.out.println(weakReference.get());
    }
}
